package com.huangjue.backend.config;

import com.huangjue.backend.filter.EncryptionFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 过滤器配置类
 * 注册加密解密过滤器
 */
@Configuration
public class FilterConfig {
    
    /**
     * 注册加密解密过滤器
     * 优先级设置为最高，确保在所有其他过滤器之前执行
     */
    @Bean
    public FilterRegistrationBean<EncryptionFilter> encryptionFilterRegistration() {
        FilterRegistrationBean<EncryptionFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new EncryptionFilter());
        registration.addUrlPatterns("/*"); // 拦截所有请求
        registration.setName("encryptionFilter");
        registration.setOrder(1); // 设置最高优先级
        return registration;
    }
} 